import { t } from '@/locale/index'
import $http from "@/common/http"

export default function usePayment(provider, order_id) {
  return new Promise((resolve, reject) => {
    $http.post(`orders/${order_id}/pay`).then((res) => {
      uni.requestPayment({
        provider: provider,
        orderInfo: res,
        success: function (res) {
          resolve(res)
        },
        fail: function (err) {
          reject(err)
        },
        complete: function (res) {
          console.log(res);
        }
      })
    }).catch((err) => {
      reject(err)
    })
  })
}